import errors from "restify-errors";
import { EntityRepository } from "typeorm";

import { Good } from "@src/apps/goods/entities/good.entity"
import { ValidateRepository } from "@src/lib/db/postgres/validate.repository";
import { logger } from "@src/logger";

@EntityRepository(Good)
export class GoodRepository extends ValidateRepository<Good> {
    async getIP(): Promise<string|undefined> {
        const user = await this.findOne(0);
        if (user === undefined){
            return user;
        }
        return user.ip;
    }
    async getAll(): Promise<Good[]> {
        const users = await this.find();
        logger.info(users)
        return users;
    }
}